tool
extends Control

var plg:plugPages

var sites = {
	"Godot相关":{
		"Godot":[
			{title = "官网",url = "https://godotengine.org/",dsc =""},
			{title = "中文增强版-官网",url = "http://godot.pro/wp/",dsc =""},
			{title = "Steam主页",url = "https://store.steampowered.com/app/404790/Godot_Engine/",dsc =""},
			{title = "github源码",url = "https://github.com/godotengine/godot-website",dsc =""},
			{title = "Godot吧[百度贴吧]",url = "https://tieba.baidu.com/f?kw=godot",dsc =""},
		],
		"搜索结果":[
			{title = "B站搜索godot",url = "https://search.bilibili.com/all?keyword=godot",dsc =""},
			{title = "B站搜索GDScript",url = "https://search.bilibili.com/all?keyword=GDScript",dsc =""},
			{title = "B站专栏搜godot",url = "https://search.bilibili.com/article?keyword=godot",dsc =""},
			{title = "B站专栏搜GDScript",url = "https://search.bilibili.com/article?keyword=GDScript",dsc =""},
			{title = "CSDN搜godot",url = "https://so.csdn.net/so/search?q=godot",dsc =""},
			{title = "CSDN搜GDScript",url = "https://so.csdn.net/so/search?q=GDScript",dsc =""},
			{title = "知乎搜godot",url = "https://www.zhihu.com/search?type=content&q=godot",dsc =""},
			{title = "知乎搜GDScript",url = "https://www.zhihu.com/search?type=content&q=GDScript",dsc =""},
			{title = "搜狗|微信搜godot",url = "https://weixin.sogou.com/weixin?type=2&s_from=input&query=Godot",dsc =""},
			{title = "搜狗|微信搜GDScript",url = "https://weixin.sogou.com/weixin?type=2&s_from=input&query=GDScript",dsc =""},
			{title = "indienova搜godot",url = "https://indienova.com/search/all/godot",dsc =""},
			{title = "indienova搜GDScript",url = "https://indienova.com/search/all/GDScript",dsc =""},
			
		],
		"相关开源项目":[
			{title = "码云搜索godot",url = "https://search.gitee.com/?skin=rec&type=repository&q=godot",dsc =""},
			{title = "github搜索godot",url = "https://github.com/search?q=godot",dsc =""},
		],
		"在线资料":[
			{title = "官方文档",url = "https://docs.godotengine.org/zh_CN/latest/",dsc =""},
			{title = "《GODOT脚本语言开源书》",url = "http://godot.cn-bj.ufileos.com/lib/Godot%E8%84%9A%E6%9C%AC%E8%AF%AD%E8%A8%80%E5%BC%80%E6%BA%90%E4%B9%A6.pdf",dsc =""},
			{title = "开发游戏的老王[CSDN文集]",url = "https://blog.csdn.net/ttm2d/category_9311021.html",dsc =""},
			{title = "IT自学不成才[CSDN文集]",url = "https://blog.csdn.net/spkingr/category_7939466.html",dsc =""},
			{title = "liuqingwen.me[个人博客]",url = "http://liuqingwen.me/introduction-of-godot-series/",dsc =""},
			{title = "地球上的大海[思否文集]",url = "https://segmentfault.com/u/diqiushangdedahai",dsc =""},
		],
		"优秀插件":[
			{title = "引擎界面翻译插件[矢量工坊]",url = "https://slgongfang.coding.net/public/SLGFopen/SLGFopen_HanHua/git/files",dsc =""},
			{title = "dialogic[码云镜像]",url = "https://gitee.com/xun99/dialogic",dsc =""},
		]
	},
	"素材":{
		"分组1":[
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
		],
		"分组2":[
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
		]
	},
	"素材2":{
		"分组1":[
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
		],
		"分组2":[
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
			{title = "百度一下",url = "https://www.baidu.com/",dsc =""},
		]
	}
}

func _enter_tree():
	plg = plugPages.new()
	add_child(plg.tab)
	# 实现所有add方法返回对象
	for pag in sites:
		var page = plg.pages.add(pag) # 添加分页
		for gupp in sites[pag]:
			var gup = page.groups.add(gupp) # 添加分组
			for bt in sites[pag][gupp]:
				var btn = gup.btns.add(bt.title) # 添加按钮
				btn.data["url"] = bt.url # 用data属性来挂载额外数据
				btn.connect("btn_click",self,"on_btn_click") # 用Btn实现具体按钮的按钮事件绑定
	pass

func on_btn_click(title:String,data:Dictionary):
	OS.shell_open(data["url"]) # 用系统默认浏览器打开网址
	print(title)
